* clear the workspace
clear

* load data
use "Hollibaugh-Krause Budget Replication Data.dta"

* generate divided government
gen divided = 1-unified

* define "unreliable"
gen unreliable_tercile = fealtyideosubHL_tercile_ols + fealtyideosubLH_tercile_ols
gen unreliable_quintile = fealtyideosubHL_quintile_ols + fealtyideosubLH_quintile_ols
gen unreliable_quartile = fealtyideosubHL_ols + fealtyideosubLH_ols

* generate agency alignment data
gen presagencyally = 0
replace presagencyally = 1 if presallyagencyideol == 1
replace presagencyally = . if presallyagencyideol == .

gen presagencyopposed = 0 
replace presagencyopposed = 1 if presallyagencyideol == -1
replace presagencyopposed = . if presallyagencyideol == .

* agencies with < 8 observations
gen smallagency = 0
replace smallagency = 1 if agencyname == "Homeland Security"
replace smallagency = 1 if agencyname == "USIA/BBG"
replace smallagency = 1 if agencyname == "Housing and Urban Development (HUD)"
replace smallagency = 1 if agencyname == "Defense (Civil Programs)"


* party-agency FEs
gen dempres = clinton + obama
egen partyagencyFE = concat(dempres agency), punct(-)
encode partyagencyFE, gen(PAFE)


*** tables
** for all tables, the lincoms are the H1 tests at the bottom of the table in the paper/appendix

* table 1
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-1.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table 2
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-2.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted drop(*.agency) scalars(ll bic chi2 p chi2_c p_c) replace


* table B-1
eststo clear
eststo: quietly hetregress rel_ldba_asinh c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_asinh]fealtyideocompHH_tercile_ols - [rel_ldba_asinh]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_asinh c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_asinh]fealtyideocompHH_tercile_ols - [rel_ldba_asinh]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_asinh c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [rel_ldba_asinh]fealtyideocompHH_tercile_ols - [rel_ldba_asinh]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_asinh c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [rel_ldba_asinh]fealtyideocompHH_tercile_ols - [rel_ldba_asinh]fealtyideocompLL_tercile_ols

esttab using "Table-B1.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se drop(*.agency) noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-2
eststo clear
eststo: reg abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

eststo: reg abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

eststo: reg rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

eststo: reg rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

esttab using "Table-B2.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se scalars(r2) noomitted replace


* table B-3
eststo clear
eststo: reg abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

eststo: reg abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols clinton i.agency, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

eststo: reg rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

eststo: reg rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols clinton i.agency, vce(cluster agency) 
lincom fealtyideocompHH_tercile_ols - fealtyideocompLL_tercile_ols

esttab using "Table-B3.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se drop(*.agency) scalars(r2) noomitted replace


* table B-4
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_quartile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_ols - [abs_ldba]fealtyideocompLL_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_quartile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_ols - [abs_ldba]fealtyideocompLL_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_quartile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_ols - [rel_ldba_change]fealtyideocompLL_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_quartile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_ols - [rel_ldba_change]fealtyideocompLL_ols

esttab using "Table-B4.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-5
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_quartile i.agency)
lincom [abs_ldba]fealtyideocompHH_ols - [abs_ldba]fealtyideocompLL_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_quartile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_ols - [abs_ldba]fealtyideocompLL_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_quartile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_ols - [rel_ldba_change]fealtyideocompLL_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_ols c.divided##c.fealtyideocompLL_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_quartile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_ols - [rel_ldba_change]fealtyideocompLL_ols

esttab using "Table-B5.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se  drop(*.agency) noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-6
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_quintile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_quintile_ols - [abs_ldba]fealtyideocompLL_quintile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_quintile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_quintile_ols - [abs_ldba]fealtyideocompLL_quintile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_quintile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_quintile_ols - [rel_ldba_change]fealtyideocompLL_quintile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(c.divided##c.unreliable_quintile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_quintile_ols - [rel_ldba_change]fealtyideocompLL_quintile_ols

esttab using "Table-B6.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-7
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_quintile i.agency)
lincom [abs_ldba]fealtyideocompHH_quintile_ols - [abs_ldba]fealtyideocompLL_quintile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_quintile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_quintile_ols - [abs_ldba]fealtyideocompLL_quintile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols i.agency, vce(cluster agency) het(c.divided##c.unreliable_quintile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_quintile_ols - [rel_ldba_change]fealtyideocompLL_quintile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_quintile_ols c.divided##c.fealtyideocompLL_quintile_ols i.agency clinton, vce(cluster agency) het(c.divided##c.unreliable_quintile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_quintile_ols - [rel_ldba_change]fealtyideocompLL_quintile_ols

esttab using "Table-B7.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted drop(*.agency) scalars(ll bic chi2 p chi2_c p_c) replace


* table B-8
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B8.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-9
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton if smallagency == 0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B9.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-10
eststo clear
eststo: quietly hetregress abs_ldba abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B10.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-11
eststo clear
eststo: quietly hetregress abs_ldba abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile i.agency)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change abs_ldba_lag c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton, vce(cluster agency) het(abs_ldba_lag c.divided##c.unreliable_tercile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B11.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted drop(*.agency) scalars(ll bic chi2 p chi2_c p_c) replace


* table B-12
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B12.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-13
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton if ldba >=0, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B13.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted drop(*.agency) scalars(ll bic chi2 p chi2_c p_c) replace


* table B-14
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B14.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted scalars(ll bic chi2 p chi2_c p_c) replace


* table B-15
eststo clear
eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [abs_ldba]fealtyideocompHH_tercile_ols - [abs_ldba]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

eststo: quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols i.agency clinton if fiscal_year != 2002, vce(cluster agency) het(c.divided##c.unreliable_tercile i.agency clinton)
lincom [rel_ldba_change]fealtyideocompHH_tercile_ols - [rel_ldba_change]fealtyideocompLL_tercile_ols

esttab using "Table-B15.html", star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) se noomitted drop(*.agency) scalars(ll bic chi2 p chi2_c p_c) replace



*** Figure 2
quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompHH_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) expression(exp(predict(xb)-1)/1000000) coeflegend post
xlincom loyal = _b[fealtyideocompHH_tercile_ols:1bn._at], post
estimates store HH_unified_xlincom

quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompHH_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) expression(exp(predict(xb)-1)/1000000) coeflegend post
xlincom loyal = _b[fealtyideocompHH_tercile_ols:2bn._at], post
estimates store HH_divided_xlincom

quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) expression(exp(predict(xb)-1)/1000000) coeflegend post
xlincom disloyal = _b[fealtyideocompLL_tercile_ols:1bn._at], post
estimates store LL_unified_xlincom

quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) expression(exp(predict(xb)-1)/1000000) coeflegend post
xlincom disloyal = _b[fealtyideocompLL_tercile_ols:2bn._at], post
estimates store LL_divided_xlincom

quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols fealtyideocompHH_tercile_ols) at(divided = 0 unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) expression(exp(predict(xb)-1)/1000000) coeflegend post
xlincom diff = _b[fealtyideocompHH_tercile_ols] - _b[fealtyideocompLL_tercile_ols], post
estimates store unified_diff

quietly hetregress abs_ldba c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols fealtyideocompHH_tercile_ols) at(divided = 1 unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) expression(exp(predict(xb)-1)/1000000) coeflegend post
xlincom diff = _b[fealtyideocompHH_tercile_ols] - _b[fealtyideocompLL_tercile_ols], post
estimates store divided_diff

coefplot (HH_unified_xlincom, label(Unified Government) offset(0.05) pstyle(p1)) (HH_divided_xlincom, label(Divided Government) offset(-0.05) pstyle(p2)) (LL_unified_xlincom, label(Unified Government) offset(0.05) pstyle(p1)) (LL_divided_xlincom, label(Divided Government) offset(-0.05) pstyle(p2)) (unified_diff, label(Unified Government) offset(0.05) pstyle(p1)) (divided_diff, label(Divided Government) offset(-0.05) pstyle(p2)), xline(0, lwidth(thin) lpattern(dash)) levels(95 90) scheme(s1mono)  xtitle("Marginal Effect of Agency Head Type on LDBA" "(in Billions of Dollars)") ytitle(Type of Appointee) coeflabels(loyal = "Strong Presidential Loyalist" disloyal = "Weak Presidential Loyalist" diff = `""Difference in" "Marginal Effects" "(Strong - Weak)""') ciopts(recast(. rcap)) legend(order(3 "Unified Government" 6 "Divided Government"))

graph export Figure-2.pdf, replace
graph export Figure-2.png, replace



*** Figure 3
quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompHH_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) coeflegend post
xlincom loyal = _b[fealtyideocompHH_tercile_ols:1bn._at], post
estimates store HH_unified_xlincom_rel

quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompHH_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) coeflegend post
xlincom loyal = _b[fealtyideocompHH_tercile_ols:2bn._at], post
estimates store HH_divided_xlincom_rel

quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) coeflegend post
xlincom disloyal = _b[fealtyideocompLL_tercile_ols:1bn._at], post
estimates store LL_unified_xlincom_rel

quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols) at(divided = (0 1) unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0)  coeflegend post
xlincom disloyal = _b[fealtyideocompLL_tercile_ols:2bn._at], post
estimates store LL_divided_xlincom_rel

quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols fealtyideocompHH_tercile_ols) at(divided = 0 unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) coeflegend post
xlincom diff = _b[fealtyideocompHH_tercile_ols] - _b[fealtyideocompLL_tercile_ols], post
estimates store unified_diff_rel

quietly hetregress rel_ldba_change c.divided##c.fealtyideocompHH_tercile_ols c.divided##c.fealtyideocompLL_tercile_ols c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou, vce(cluster agency) het(c.divided##c.unreliable_tercile c.divided##c.presagencyally c.divided##c.presagencyopposed dmaker_ind polrev_ind sou)
margins, dydx(fealtyideocompLL_tercile_ols fealtyideocompHH_tercile_ols) at(divided = 1 unreliable_tercile= 0 fealtyideocompLL_tercile_ols = 0 fealtyideocompHH_tercile_ols = 0) coeflegend post
xlincom diff = _b[fealtyideocompHH_tercile_ols] - _b[fealtyideocompLL_tercile_ols], post
estimates store divided_diff_rel

coefplot (HH_unified_xlincom_rel, label(Unified Government) offset(0.05) pstyle(p1)) (HH_divided_xlincom_rel, label(Divided Government) offset(-0.05) pstyle(p2)) (LL_unified_xlincom_rel, label(Unified Government) offset(0.05) pstyle(p1)) (LL_divided_xlincom_rel, label(Divided Government) offset(-0.05) pstyle(p2)) (unified_diff_rel, label(Unified Government) offset(0.05) pstyle(p1)) (divided_diff_rel, label(Divided Government) offset(-0.05) pstyle(p2)), xline(0, lwidth(thin) lpattern(dash)) levels(95 90) scheme(s1mono)  xtitle("Marginal Effect of Agency Head Type on Relative LDBA " "(Weighted Average Percentage Change)") ytitle(Type of Appointee) coeflabels(loyal = "Strong Presidential Loyalist" disloyal = "Weak Presidential Loyalist" diff = `""Difference in" "Marginal Effects" "(Strong - Weak)""') ciopts(recast(. rcap)) legend(order(3 "Unified Government" 6 "Divided Government"))


graph export Figure-3.pdf, replace
graph export Figure-3.png, replace


** table A-1
su abs_ldba rel_ldba_change fealtyideocompHH_tercile_ols fealtyideocompHH_tercile_ols unreliable_quintile divided presagencyally presagencyopposed dmaker_ind polrev_ind sou clinton
